# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=libatomic_ops
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=7.6.10
pkgrel=1
pkgdesc="Provides semi-portable access to hardware provided atomic memory operations (mingw-w64)"
arch=('any')
url="https://www.hboehm.info/gc"
license=('GPL2' 'MIT')
source=("https://github.com/ivmai/${_realname}/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz")
sha256sums=('587edf60817f56daf1e1ab38a4b3c729b8e846ff67b4f62a6157183708f099af')

prepare(){
  cd ${srcdir}/${_realname}-${pkgver}
  
  ./autogen.sh
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p ${srcdir}/build-${MINGW_CHOST} && cd ${srcdir}/build-${MINGW_CHOST}

  ../${_realname}-${pkgver}/configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-shared \
    --enable-static
  make
}

check() {
  cd ${srcdir}/build-${MINGW_CHOST}
  PATH="${srcdir}//build-${MINGW_CHOST}/src/.libs:$PATH" make check || true
}

package() {
  cd ${srcdir}/build-${MINGW_CHOST}
  make DESTDIR="${pkgdir}" install
  install -D -m644 ${srcdir}/${_realname}-${pkgver}/doc/LICENSING.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE"
}
